"""
员工管理管理模块的增删改查 的接口对象层
"""
import requests



class ApiIhrmEmpCrud(object):
    def __init__(self):
        pass
    def add_emp(self, header, json_data):
        url = "https://ihrm-test.itheima.net/api/sys/user"
        resp = requests.post(url=url, headers=header, json=json_data)
        return resp
    # 查询员工
    def get_emp(self,emp_id, header):
        url = "https://ihrm-test.itheima.net/api/sys/user" + emp_id
        resp = requests.get(url=url, headers=header)
        return resp
    # 修改员工
    def modify_emp(self, emp_id, header, json_data):
        url = "https://ihrm-test.itheima.net/api/sys/user" + emp_id
        resp = requests.put(url=url, headers=header, json=json_data)
        return resp
    # 删除员工
    def delete_emp(self, emp_id, header):
        url = "https://ihrm-test.itheima.net/api/sys/user" + emp_id
        resp = requests.delete(url=url, headers=header)
        return resp

if __name__ == '__main__':
    header = {"Content-Type": "application/json","Authorization": "Bearer b040daed-39c1-4302-8777-f950770c8a26"}
    data_add = {"username": "业务猪001", "mobile": "13978734786", "workNumber": "9527"}
    api_ihrm_emp_crud = ApiIhrmEmpCrud()
    resp = api_ihrm_emp_crud.add_emp(header, data_add)
    print("添加：", resp.json())
    emp_id = "1469572901224054784"
    resp = api_ihrm_emp_crud.get_emp(emp_id, header)
    print("查询：", resp.json())
    data = {"username": "齐天大圣"}
    resp = api_ihrm_emp_crud.modify_emp(emp_id, header, data)
    print("修改：", resp.json())
    resp = api_ihrm_emp_crud.delete_emp(emp_id, header)
    print("删除：", resp.json())

